#include "cilantro.h"
#include "cfgengine.h"





int cilantro_config_init( struct cilantro_config_t ** p ) {
	
	*p = (struct cilantro_config_t * ) malloc( sizeof(struct cilantro_config_t));
	memset( (*p), '\0', sizeof(struct cilantro_config_t));

	if( !(*p) )
	{
		return FALSE;
	}

	config_init( (*p)->cfg );	
	strncpy( (*p)->filename, CONFIG_FILENAME, 128);

	printf("[cfgengine.c] Inited cfgengine object\n");
	return TRUE;
}

int cilantro_config_read( struct cilantro_config_t ** p) {
		
		if( config_read( (*p)->cfg, (*p)->filename) == CONFIG_FALSE) {
			printf("[cfgengine.c] Unable to open config file : %s\n", (*p)->filename);
			return FALSE;
		}

		config_lookup_string( (*p)->cfg, "cilantro.sql.db", (*p)->db_name );
		config_lookup_string( (*p)->cfg, "version", (*p)->version );

		
		return TRUE;
}

int cilantro_config_write( struct cilantro_config_t ** p ) {
	
	
	return TRUE;
}

int cilantro_config_destroy(struct cilantro_config_t ** p ) {
	
	config_destroy( (*p)->cfg );
	free(*p); 

	return TRUE;
}
